package com.ynwa.jvm;

/**
 * @author gzd
 * @date 2018-10-08 下午 3:02
 * @desc 12 | 垃圾回收（下）
 * jvm运行参数，-XX:+PrintGC(打印GC日志) -Xmn100M(新生代最大内存100M)
 * -XX:PretenureSizeThreshold=10000(超过这个值，直接在老年代分配对象)
 */
public class GCTest {
    private static final int K = 1024;
    private static final int M = K * K;
    private static final int G = K * M;

    private static final int ALIVE_OBJECT_SIZE = 32 * M;

    public static void main(String[] args) {
        int length = ALIVE_OBJECT_SIZE / 64;
        ObjectOf64Bytes[] array = new ObjectOf64Bytes[length];
        for (long i = 0; i < G; i++) {
            array[(int) (i % length)] = new ObjectOf64Bytes();
        }
    }
}
